package licode.unisop.client.feign.impl;

import licode.unisop.client.feign.SoAssetRelVisitFeign;
import licode.unisop.client.visit.AssetRelQueryVisit;
import licode.unisop.client.visit.UniClientTool;
import licode.unisop.client.vo.SopAsset;
import licode.unisop.client.vo.SopAuthPlatform;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 定义统一认证平台中心资源相关接口
 *
 * @author licode
 */
@Component
public class AssetRelQueryVisitFeignImpl implements AssetRelQueryVisit {
    @Resource
    private HttpServletRequest request;

    @Resource
    private UniClientTool uniClientTool;

    @Resource
    private SoAssetRelVisitFeign soAssetRelVisitFeign;

    @Override
    public Object queryPage(Map<String, Object> req) {
        SopAuthPlatform authPlatform;
        authPlatform = uniClientTool.findAuthPlatform(request, "");
        return soAssetRelVisitFeign.queryPage(authPlatform.getPlatformId(),
                authPlatform.getModelToken(), req).getData();
    }

    @Override
    public Object queryMovePage(Map<String, Object> req) {
        SopAuthPlatform authPlatform;
        authPlatform = uniClientTool.findAuthPlatform(request, "");
        return soAssetRelVisitFeign.queryMovePage(authPlatform.getPlatformId(),
                authPlatform.getModelToken(), req).getData();
    }

    @Override
    public Object queryAllByLevel(Map<String, Object> req) {
        SopAuthPlatform authPlatform;
        authPlatform = uniClientTool.findAuthPlatform(request, "");
        return soAssetRelVisitFeign.queryAllByLevel(authPlatform.getPlatformId(),
                authPlatform.getModelToken(), req).getData();
    }

    @Override
    public Object queryPageByLevel(Map<String, Object> req) {
        SopAuthPlatform authPlatform;
        authPlatform = uniClientTool.findAuthPlatform(request, "");
        return soAssetRelVisitFeign.queryPageByLevel(authPlatform.getPlatformId(),
                authPlatform.getModelToken(), req).getData();
    }

    @Override
    public Object queryAssetsOfHolderPage(Map<String, Object> req) {
        SopAuthPlatform authPlatform;
        authPlatform = uniClientTool.findAuthPlatform(request, "");
        return soAssetRelVisitFeign.queryAssetsOfHolderPage(authPlatform.getPlatformId(),
                authPlatform.getModelToken(), req).getData();
    }

    @Override
    public Object queryHoldersOfAssetPage(Map<String, Object> req) {
        SopAuthPlatform authPlatform;
        authPlatform = uniClientTool.findAuthPlatform(request, "");
        return soAssetRelVisitFeign.queryHoldersOfAssetPage(authPlatform.getPlatformId(),
                authPlatform.getModelToken(), req).getData();
    }

    @Override
    public Map<String, Object> loadAttributesOfAsset(Map<String, Object> req) {
        SopAuthPlatform authPlatform;
        authPlatform = uniClientTool.findAuthPlatform(request, "");
        return soAssetRelVisitFeign.loadAttributesOfAsset(authPlatform.getPlatformId(),
                authPlatform.getModelToken(), req).getData();
    }

}
